<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- react的根元素 插入一个根组件 -->
    <div id="example"></div>
</body>
</html>
<script src="./js/react.development.js"></script>
<script src="./js/react-dom.development.js"></script>
<script src="./js/babel.js"></script>
<script type="text/babel">
    class MyComponent extends React.Component{
        constructor(props)
        {
            super(props)

            this.state = {
                list: [
                    {username:'zs1',age:20,id:"01"},
                    {username:'zs2',age:21,id:"02"},
                    {username:'zs3',age:22,id:"03"},
                    {username:'zs4',age:23,id:"04"},
                ]
            }
        }

        render()
        {
            const items = this.state.list.map((item, index) => {
                return (
                    <li key={item.id}>
                        {index+1}. <span>用户名: {item.username}</span> <span>年龄: {item.age}</span>
                    </li>
                )
            })

            return (
                <div>
                    <ul>
                        {
                            this.state.list.map((item,index)=> {
                                return (
                                    <li key={item.id}>
                                        {index+1}. <span>用户名: {item.username}</span> <span>年龄: {item.age}</span>
                                    </li>
                                )
                            })
                        }    
                    </ul>

                    <ul>
                        {items}
                    </ul>
                </div>
                
            )
        }
    }

    ReactDOM.render(
        <MyComponent />,
        document.getElementById('example')
    )
</script>